home *** CD-ROM | disk | FTP | other *** search
-
- #define __USE_SYSBASE
- #include <proto/exec.h>
- #include <proto/intuition.h>
- #include <proto/dos.h>
- #include <proto/muimaster.h>
-
- #include <libraries/mui.h>
- #include <libraries/CManager.h>
- #include <utility/hooks.h>
-
- #include <clib/alib_protos.h>
-
- #include <mui/textinput_mcc.h>
- #include <mui/CManager_mcc.h>
-
- #include <stdio.h>
- #include <string.h>
-
- /***************************************************************************/
-
- #define SAVEDS __saveds
- #define ASM __asm
- #define STDARGS __stdargs
- #define REG(x) register __ ## x
- #define MAKE_ID(a,b,c,d) ((ULONG)(a)<<24|(ULONG)(b)<<16|(ULONG)(c)<<8|(ULONG)(d))
-
- /***************************************************************************/
-
- struct data
- {
- Object *pop; /* The Popobject in itself */
- Object *popString; /* The String object of the Popobject */
- ULONG dataLoad; /* Flag, if 0 load data in CManager */
- };
-
- /***************************************************************************/
-
- long __stack = 64000;
- struct Library *MUIMasterBase;
-
- /***********************************************************************/
- /*
- ** We just check if data are to be load in CManager
- */
-
- ULONG ASM SAVEDS
- strObjFun(REG(a0) struct Hook *hook,REG(a1) Object *popString,REG(a2) Object *popObject)
- {
- register struct data *data = hook->h_Data;
-
- if (!data->dataLoad)
- {
- DoMethod(popObject,MUIM_CManager_LoadData,NULL,NULL);
- data->dataLoad = 1;
- }
-
- return TRUE;
- }
-
- /***************************************************************************/
- /*
- ** Set the string contents and close the pop
- */
-
- ULONG SAVEDS ASM
- appDoubleClickFun(REG(a0) struct Hook *hook,REG(a1) struct CMWWW *entry,REG(a2) Object *cm)
- {
- register struct data *data = hook->h_Data;
- register STRPTR s;
-
- switch (entry->Type)
- {
- case CME_WWW:
- s = entry->WWW;
- break;
-
- case CME_FTP:
- s = ((struct CMFTP *)entry)->FTP;
- }
-
- set(data->popString,MUIA_Textinput_Contents,s);
- DoMethod(data->pop,MUIM_Popstring_Close,TRUE);
-
- return 0;
- }
-
- /***************************************************************************/
-
- int
- main(int argc,char **argv)
- {
- register int res = RETURN_ERROR;
-
- if (MUIMasterBase = OpenLibrary("muimaster.library",19))
- {
- struct data data;
- struct Hook strObjHook, appDoubleClickHook;
- Object *app, *win, *cm;
-
- if (app = ApplicationObject,
- MUIA_Application_Title, "CMURL",
- MUIA_Application_Version, "$VER: CMURL 1.1 (18.3.2003)",
- MUIA_Application_Copyright, "Copyright 2003 by Alfonso Ranieri",
- MUIA_Application_Author, "Alfonso Ranieri <alforan@tin.it>",
- MUIA_Application_Description, "CManager.mcc example",
- MUIA_Application_Base, "CMURL",
-
- SubWindow, win = WindowObject,
- MUIA_Window_ID, MAKE_ID('M','A','I','N'),
- MUIA_Window_Title, "CMURL",
-
- WindowContents, VGroup,
- Child, HGroup,
- Child, Label1("_URL"),
- Child, data.pop = PopobjectObject,
- MUIA_Popobject_StrObjHook, &strObjHook,
- MUIA_Popstring_String, data.popString = TextinputObject,
- StringFrame,
- MUIA_Textinput_MaxLen, 256,
- MUIA_ControlChar, 'u',
- End,
- MUIA_Popstring_Button, PopButton(MUII_PopUp),
- MUIA_Popobject_Object, cm = CManagerObject,
- MUIA_Frame, MUIV_Frame_InputList,
- MUIA_CManager_AppDoubleClick, &appDoubleClickHook,
- MUIA_CManager_HideUsers, TRUE,
- MUIA_CManager_HideChat, TRUE,
- MUIA_CManager_HideTelnet, TRUE,
- MUIA_CManager_NoMenu, TRUE,
- End,
- End,
- End,
- End,
- End,
- End)
- {
- ULONG signals;
-
- data.dataLoad = 0;
-
- strObjHook.h_Entry = (HOOKFUNC)strObjFun;
- strObjHook.h_Data = &data;
-
- appDoubleClickHook.h_Entry = (HOOKFUNC)appDoubleClickFun;
- appDoubleClickHook.h_Data = &data;
-
- DoMethod(win,MUIM_Notify,MUIA_Window_CloseRequest,TRUE,MUIV_Notify_Application,2,MUIM_Application_ReturnID,MUIV_Application_ReturnID_Quit);
-
- set(win,MUIA_Window_Open,TRUE);
-
- for (signals = 0; DoMethod(app,MUIM_Application_NewInput,&signals)!=MUIV_Application_ReturnID_Quit; )
- if (signals && ((signals = Wait(signals | SIGBREAKF_CTRL_C)) & SIGBREAKF_CTRL_C)) break;
-
- MUI_DisposeObject(app);
-
- res = RETURN_OK;
- }
- else
- {
- Printf("%s: can't create application\n",argv[0]);
- res = RETURN_FAIL;
- }
-
- CloseLibrary(MUIMasterBase);
- }
- else Printf("%s: Can't open muimaster.library ver 19 or higher\n",argv[0]);
-
- return res;
- }
-
- /***********************************************************************/
-